//格式化时间差
export function formatTimeDifference(timestamp : number) : string {
    let now = new Date();
    let diff = now.getTime() - timestamp;
    let diffSeconds = Math.floor(diff / 1000);
    let diffMinutes = Math.floor(diffSeconds / 60);
    let diffHours = Math.floor(diffMinutes / 60);
    let diffDays = Math.floor(diffHours / 24);
    let diffMonths = Math.floor(diffDays / 30);

    if (diffMinutes < 1) {
        return "1分钟内";
    } else if (diffMinutes < 60) {
        return `${diffMinutes}分钟前`;
    } else if (diffHours < 24) {
        return `${diffHours}小时前`;
    } else if (diffDays < 30) {
        return `${diffDays}天前`;
    } else if (diffMonths < 3) {
        return `${diffMonths}月前`;
    } else {
        return "3月前";
    }
};